package org.xinjiang.data.migration.flush.convert;

import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.xinjiang.data.migration.flush.utils.DefaultUtils;
import org.xinjiang.data.migration.hainan.entity.SysDepart;

import java.util.ArrayList;
import java.util.Collection;

;

/**
 * @author: 邢卫
 * @date: 2023年12月15日 10:35
 */
@Component
public class DepartConvert extends BaseConvert<org.xinjiang.data.migration.xinjiang.entity.WegovOrgTeam, SysDepart> {

    @Override
    public SysDepart convert(org.xinjiang.data.migration.xinjiang.entity.WegovOrgTeam team) {
        SysDepart depart = new SysDepart();
        depart.setId(team.getStTeamId());
        depart.setSourceId(team.getStTeamId());
        depart.setDepartName(DefaultUtils.toDepartName(team.getStTeamName(), team.getStTeamLevel()));
//        depart.setDepartNameEn();//没有
        depart.setDepartNameAbbr(team.getStTeamAbbrName());
        depart.setDepartOrder(team.getNmTeamOrder());
        depart.setDescription(team.getStDescription());
        depart.setOrgCategory("1");//在那时给1
//        depart.setOrgType();//后期给补充
        depart.setOrgCode(generateRandomString());//生成
        depart.setLinkMan(team.getStTeamPhone());
        depart.setMobile(team.getStLiaisonMobile());
        depart.setFax(team.getStTeamFax());
        depart.setAddress(team.getStTeamAddress());
        depart.setGroupType(DefaultUtils.toGroupType(team.getStTeamLevel()));
//        depart.setMemo();//没有
        depart.setDelFlag(team.getStIsDeleted());
        depart.setStatus("1".equals(depart.getDelFlag()) ? "0" : "1");
        depart.setCreateBy(team.getStCreateId());
        depart.setCreateTime(team.getDtCreateTime());
        depart.setUpdateTime(team.getDtUpdateTime());
        return depart;
    }

    @Override
    public Collection<SysDepart> converts(Collection<org.xinjiang.data.migration.xinjiang.entity.WegovOrgTeam> ss) {
        Collection<SysDepart> collection = new ArrayList<>();
        if (CollectionUtils.isEmpty(ss)) {
            return collection;
        }
        for (org.xinjiang.data.migration.xinjiang.entity.WegovOrgTeam s : ss) {
            collection.add(convert(s));
        }
        return collection;
    }
}
